#ifndef EXITCHILD_HANDLER_H_
#define EXITCHILD_HANDLER_H_

#include <assert.h>
#include <EventHandler.h>

#include "Handlers.h"
#include "../../view/MenuStack.h"

class EXITCHILD_Handler : public EventHandler {

	private:
		bool childExit;

	public:

		EXITCHILD_Handler () {
			childExit = false;
		}

		/*
		 * Maneja la interrupcion de un proceso hijo para
		 * su correcta finalizacion
		 */
		virtual int handleSignal ( int signum ) {
			assert ( signum == EXITCHILD_SIGNAL );
			while (!MenuStack::getInstance()->empty()) {
				MenuStack::getInstance()->pop();
			}
			childExit = true;
			return 0;
		}

		/*
		 * Devuelve true si se recibio esta señal
		 */
		bool isChildExit() {
			return childExit;
		}
};

#endif /* EXITCHILD_HANDLER_H_ */
